package pres.man.interview.collection;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * 不安全的list
 *
 * @Author MAN
 * @Date 2021-01-20-16:35
 */
public class UnSafeList {

    private final static List<Integer> LIST = new ArrayList<>();

    public static void main(String[] args) {
//        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(8, 8, 3, TimeUnit.SECONDS, new ArrayBlockingQueue<>(10), new ThreadPoolExecutor.CallerRunsPolicy());
//
//        AtomicInteger atomicInteger = new AtomicInteger(0);
//        for (int i = 0; i < 100; i++) {
//            poolExecutor.execute(() -> {
//                LIST.add(atomicInteger.incrementAndGet());
//                System.out.println(LIST);
//            });
//            poolExecutor.execute(() -> {
//                LIST.add(atomicInteger.incrementAndGet());
//                System.out.println(LIST);
//            });
//        }
        LIST.add(1);
        LIST.add(2);
        LIST.add(3);
        LIST.add(4);
        LIST.remove(-5);

    }
}
